//
//  BusinessViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/8.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "ConvenienceDetailViewController.h"
#import "RDVTabBarController.h"
#import "RDVTabBarItem.h"
#import "ServiceView.h"
#import "peisongCell.h"
#import "HttpRequest.h"
#import "UIButton+WebCache.h"
#import "HAODEsingleton.h"
#import "ProductView.h"
#import "MapViewControllers.h"
#import <MapKit/MapKit.h>
#import "ACETelPrompt.h"
#import "SelectTheCertificationViewController.h"
@interface ConvenienceDetailViewController ()<CLLocationManagerDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIScrollViewDelegate,UIWebViewDelegate>
@property (nonatomic, unsafe_unretained) NSInteger currentIndex;
@property(nonatomic ,strong)NSDictionary*myDic;

@end

@implementation ConvenienceDetailViewController
{
    HAODEsingleton *commdity;
    ServiceView *mainScorllView;
    UIScrollView*mainScroll;
    UIScrollView*mainScroll1;
    NSMutableArray*LinkType;
    NSMutableArray*LinkCode;
    NSMutableArray*ImageUrl1;
    UIButton*guanzhuBtn;
    UIView*view;
     UIWebView*webview;
}
@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden=NO;
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    
       UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
   UIButton* sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
    [sxBtn setImage:[UIImage imageNamed:@"fenxiangss"] forState:UIControlStateNormal];
    [sxBtn addTarget:self action:@selector(fenxiangss:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
    self.navigationItem.rightBarButtonItem = myBtnBtn;
    

    
    
    commdity =[HAODEsingleton shared];
    

    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
   
    [param setValue:commdity.convenienceId forKey:@"convenienceId"];
    //    [param setValue:self.sats forKey:@"orderField"];
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"/Convenience/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth,ScreenHeight)];
                mainScroll.delegate = self;
                mainScroll.userInteractionEnabled = YES;
                mainScroll.scrollEnabled = YES;
                mainScroll.showsVerticalScrollIndicator = FALSE;
                mainScroll.showsHorizontalScrollIndicator = FALSE;
                mainScroll.backgroundColor=zuiqianhuicolor;
                [self .view addSubview:mainScroll];
                commdity.Dict=severDataDict.dataDict;
                if ([commdity.ctype isEqualToString:@"logistics"]) {
                    UIImageView*image=[[UIImageView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, 150)];
                    image.image=[UIImage imageNamed:@"wuliupeisongbeijing"];
                    [mainScroll addSubview:image];

                }
                if ([commdity.ctype isEqualToString:@"finance"]) {
                    UIImageView*image=[[UIImageView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, 150)];
                    image.image=[UIImage imageNamed:@"jinrongxindaibeijing"];
                    [mainScroll addSubview:image];

                }
                if ([commdity.ctype isEqualToString:@"food"]) {
                    UIImageView*image=[[UIImageView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, 150)];
                    image.image=[UIImage imageNamed:@"meishiwaimaibeijing"];
                    [mainScroll addSubview:image];

                }
                if ([commdity.ctype isEqualToString:@"handy"]) {
                    UIImageView*image=[[UIImageView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, 150)];
                    image.image=[UIImage imageNamed:@"bianminfuwubeijing"];
                    [mainScroll addSubview:image];

                }
                
                
                
                
                
                UIImageView*image1=[[UIImageView alloc]initWithFrame:CGRectMake(15, 90, 70, 70)];
                [image1 setImageWithURL:[severDataDict.dataDict objectForKey:@"imageUrl"] placeholderImage:nil];
                [image1.layer setCornerRadius:4.0];
                [image1.layer setBorderWidth:3];
                [image1.layer setMasksToBounds:YES];
                image1.layer.borderColor = zuiqianhuicolor.CGColor;

                [mainScroll addSubview:image1];
                
                view=[[UIView alloc]initWithFrame:CGRectMake(0, 150, ScreenWidth, 530/2)];
                view.backgroundColor=[UIColor whiteColor];
//                view.layer.borderWidth = 0.35;
//                view.layer.borderColor = qianhuicolor.CGColor;
                [mainScroll addSubview:view];
                UILabel*line42=[[UILabel alloc]initWithFrame:CGRectMake(15, 530/2-0.35, ScreenWidth-30, 0.35)];
                line42.backgroundColor=qianhuicolor;
                [view addSubview:line42];
                
                UIButton*linkmanImage = [[UIButton alloc]init];
                linkmanImage.frame = CGRectMake(20,125,20, 20);
                [linkmanImage setImage:[UIImage imageNamed:@"lianxirenss"] forState:UIControlStateNormal];
                [view addSubview:linkmanImage];
                UILabel*linkman=[[UILabel alloc]initWithFrame:CGRectMake(50, 110, ScreenWidth-40, 50)];
                linkman.text=[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"linkman"]];
                linkman.textColor=zhonghuiColor;
                linkman.numberOfLines=0;
                linkman.font=[UIFont systemFontOfSize:15];
                [view addSubview:linkman];
               
                
                UIButton*phoneImage = [[UIButton alloc]init];
                phoneImage.frame = CGRectMake(20,355/2,20, 20);
                [phoneImage setImage:[UIImage imageNamed:@"dianhuass"] forState:UIControlStateNormal];
                [view addSubview:phoneImage];
                UILabel*phone=[[UILabel alloc]initWithFrame:CGRectMake(50, 328/2, ScreenWidth-40, 50)];
                phone.text=[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"phone"]];
                phone.textColor=shenhuicolor;
                phone.numberOfLines=0;
                phone.font=[UIFont systemFontOfSize:15];
                [view addSubview:phone];
                UIButton*jiantouBtnjiada = [[UIButton alloc]init];
                jiantouBtnjiada.frame = CGRectMake(20,325/2,ScreenWidth, 50);
                [jiantouBtnjiada addTarget:self action:@selector(phone:) forControlEvents:UIControlEventTouchUpInside];
                [view addSubview:jiantouBtnjiada];
                UIButton*jiantouBtn = [[UIButton alloc]init];
                jiantouBtn.frame = CGRectMake(ScreenWidth-25,325/2+20,8, 13);
                [jiantouBtn setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
                [jiantouBtn addTarget:self action:@selector(phone:) forControlEvents:UIControlEventTouchUpInside];
                [view addSubview:jiantouBtn];

                
                UIButton*addressImage = [[UIButton alloc]init];
                addressImage.frame = CGRectMake(20,230,20, 20);
                [addressImage setImage:[UIImage imageNamed:@"daohangs s"] forState:UIControlStateNormal];
                [view addSubview:addressImage];
                UILabel*address=[[UILabel alloc]initWithFrame:CGRectMake(50, 215, ScreenWidth-40, 50)];
                address.text=[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"address"]];
                address.textColor=shenhuicolor;
                address.numberOfLines=0;
                address.font=[UIFont systemFontOfSize:15];
                [view addSubview:address];
                UIButton*jiantouBtnjiada1 = [[UIButton alloc]init];
                jiantouBtnjiada1.frame = CGRectMake(20,215,ScreenWidth, 50);
                [jiantouBtnjiada1 addTarget:self action:@selector(address:) forControlEvents:UIControlEventTouchUpInside];
                [view addSubview:jiantouBtnjiada1];
                UIButton*jiantouBtn1 = [[UIButton alloc]init];
                jiantouBtn1.frame = CGRectMake(ScreenWidth-25,215+20,8, 13);
                [jiantouBtn1 setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
                [jiantouBtn1 addTarget:self action:@selector(address:) forControlEvents:UIControlEventTouchUpInside];
                [view addSubview:jiantouBtn1];

                
                
                
                UILabel*title=[[UILabel alloc]initWithFrame:CGRectMake(20, 20, ScreenWidth-40, 16)];
                title.text=[severDataDict.dataDict objectForKey:@"title"];
                [view addSubview:title];
                
              NSMutableArray* arrrs=[severDataDict.dataDict objectForKey:@"tagList"];
                if (arrrs.count>0) {
                    
                    for (int i = 0,j = 0; i < arrrs.count; i++) {
                        if (i % 4 == 0) {
                            j++;
                        }
                        ProductView*clothView = [[ProductView alloc]initWithFrame:CGRectMake(20+60*(i%4), 5+(40*j), 55, 13.5)];
                        clothView.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
                        clothView.buttonView.titleLabel.font=[UIFont systemFontOfSize:10];
                        clothView.buttonView.frame = CGRectMake(0, 0, 55, 15);
                        [clothView.buttonView setTitle: [[arrrs objectAtIndex:i] objectForKey:@"content"] forState:UIControlStateNormal];
                        clothView.buttonView.backgroundColor=[UIColor whiteColor];
                        [clothView.buttonView setTitleColor:luseColor forState:0];
                        clothView.buttonView.layer.borderColor=luseColor.CGColor;
                         clothView.buttonView.layer.borderWidth = 0.35;
                        [clothView.buttonView.layer setCornerRadius:2.0];
                        
                        [view addSubview:clothView];
                        }
                   
                }
                
                        
                        
                UILabel*intro=[[UILabel alloc]initWithFrame:CGRectMake(20, 80, ScreenWidth-40, 16)];
                intro.text=[severDataDict.dataDict objectForKey:@"intro"];
                intro.textColor=shenhuicolor;
                intro.font=[UIFont systemFontOfSize:15];
                [view addSubview:intro];
                UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(15, 110, ScreenWidth-30, 0.35)];
                line.backgroundColor=qianhuicolor;
                [view addSubview:line];
                UILabel*line1=[[UILabel alloc]initWithFrame:CGRectMake(15, 320/2, ScreenWidth-30, 0.35)];
                line1.backgroundColor=qianhuicolor;
                [view addSubview:line1];
                UILabel*line2=[[UILabel alloc]initWithFrame:CGRectMake(15, 430/2, ScreenWidth-30, 0.35)];
                line2.backgroundColor=qianhuicolor;
                [view addSubview:line2];
                
            
                
                UIView*details=[[UIView alloc]initWithFrame:CGRectMake(0, view.bottom+10, ScreenWidth, ScreenHeight/2)];
                details.backgroundColor=[UIColor whiteColor];
                details.layer.borderWidth = 0.35;
                details.layer.borderColor = qianhuicolor.CGColor;
                [mainScroll addSubview:details];
                
                UILabel*details1=[[UILabel alloc]initWithFrame:CGRectMake(20, view.bottom+10, ScreenWidth-40, 45)];
                details1.text=@"详情介绍";
                details1.textColor=shenhuicolor;
                details1.font=[UIFont systemFontOfSize:15];
                [mainScroll addSubview:details1];
                UIImageView *_xianview = [[UIImageView alloc]initWithFrame:CGRectMake(15,view.bottom+45, ScreenWidth-30, 0.5)];
                _xianview.image=[UIImage imageNamed:@"hengxian"];
                [mainScroll addSubview:_xianview];
                
                
                [webview removeFromSuperview];
                webview  = [[UIWebView   alloc]  initWithFrame:CGRectMake( 0, details1.bottom,  ScreenWidth ,  ScreenHeight)];
                webview.scalesPageToFit = TRUE;
                [webview   setUserInteractionEnabled: NO ];	 //是否支持交互
                [webview   setDelegate: self ];				 //委托
                [webview   setOpaque: YES ];
                webview.backgroundColor=[UIColor clearColor];
                //透明
                UIScrollView *tempView=(UIScrollView *)[webview.subviews objectAtIndex:0];
                tempView.scrollEnabled=NO;
                [mainScroll  addSubview : webview];

                
                NSString * path =[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"detailsHtmlUrl"]];
                [webview loadRequest:[NSURLRequest requestWithURL:[[NSURL alloc] initWithString :path]]];
                
                
                
//                
//                NSString *s12 = [NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"details"]];
//                UIFont *font12 = [UIFont systemFontOfSize:15];
//                CGSize size12 = CGSizeMake(ScreenWidth-30, 2000);
//                CGSize labelsize12 = [s12 sizeWithFont:font12 constrainedToSize:size12 lineBreakMode:NSLineBreakByCharWrapping];
//            
//                UILabel*details2=[[UILabel alloc]initWithFrame:CGRectMake(20, 60, ScreenWidth-30, labelsize12.height)];
//                details2.text=[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"details"]];
//                details2.textColor=shenhuicolor;
//                details2.numberOfLines=0;
//                details2.font=[UIFont systemFontOfSize:15];
//                [details addSubview:details2];
                
               

                
                
                
               
            
            
            
            
            
            
             [self guanzhu];
            
            
            
            }else{
                [Global hideProgressHUDInternal:self.view];
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];


    
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    
    CGFloat webViewHeight = [webView.scrollView contentSize].height;
    webview.frame=CGRectMake(0, view.bottom+45, ScreenWidth, webViewHeight);
    [mainScroll setContentSize:CGSizeMake(ScreenWidth, webViewHeight+view.bottom+45)];
    
    
}
-(void)guanzhu{
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    
    [param setValue:commdity.convenienceId forKey:@"convenienceId"];

    
    [HttpRequest requestData:@"/Convenience/IsConcern" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
        [Global hideProgressHUDInternal:self.view];
                UIButton*shaixuanBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth*560/750, 60, 70,30)];
                [shaixuanBtn.layer setCornerRadius:2.0];
                [shaixuanBtn.layer setBorderWidth:0.35];
                [shaixuanBtn.layer setMasksToBounds:YES];
                [shaixuanBtn addTarget:self action:@selector(guanzhuBtn:) forControlEvents:UIControlEventTouchUpInside];
                CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){225/255.0,225/255.0, 225/255.0, 1.0   });
                [shaixuanBtn.layer setBorderColor:colorref2];//边框颜色
                [shaixuanBtn setTitle:@"     关注" forState:UIControlStateNormal];
                shaixuanBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
                [shaixuanBtn setTitleColor:shenhuicolor forState:UIControlStateNormal];
                shaixuanBtn.titleLabel.textAlignment=NSTextAlignmentRight;
                [view addSubview:shaixuanBtn];
                guanzhuBtn = [[UIButton alloc] initWithFrame:CGRectMake(2, 0, 25, 60/2)];
                
                [guanzhuBtn addTarget:self action:@selector(guanzhuBtn:) forControlEvents:UIControlEventTouchUpInside];
                [shaixuanBtn addSubview:guanzhuBtn];
                if ([[severDataDict.dataDict objectForKey:@"isConcern"]isEqualToString:@"Y"]) {
                    [guanzhuBtn setImage:[UIImage imageNamed:@"guanzhu_hights s"] forState:UIControlStateNormal];
                }else{
                
                    [guanzhuBtn setImage:[UIImage imageNamed:@"guanzhu_normals s"] forState:UIControlStateNormal];
                
                }
  
            
            }
            else{
                [Global hideProgressHUDInternal:self.view];
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];


    
}

-(void)guanzhuBtn:(UIButton *)sender{
    
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    
    [param setValue:commdity.convenienceId forKey:@"convenienceId"];
    
    [HttpRequest requestData:@"/Convenience/Concern" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                
            if ([[severDataDict.dataDict objectForKey:@"isConcern"]isEqualToString:@"Y"]) {
                    [guanzhuBtn setImage:[UIImage imageNamed:@"guanzhu_hights s"] forState:UIControlStateNormal];
                }else{
                    
                    [guanzhuBtn setImage:[UIImage imageNamed:@"guanzhu_normals s"] forState:UIControlStateNormal];
                    
                }
                
                
                
                
                
                
            }
            else{
                [Global hideProgressHUDInternal:self.view];
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==8888) {
                    
                    
                    SelectTheCertificationViewController * Login=[[SelectTheCertificationViewController alloc]init];
                    
                    [self.navigationController pushViewController:Login animated:YES];
                    
                }
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==4444) {
                    [self showAlertMessage:@"账号信息未认证通过，请从新上传"];
                    
                    SelectTheCertificationViewController * Login=[[SelectTheCertificationViewController alloc]init];
                    
                    [self.navigationController pushViewController:Login animated:YES];
                    
                }

            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
    
}

-(void)phone:(UIButton *)sender{
    
    
    [ACETelPrompt callPhoneNumber:[commdity.Dict objectForKey:@"phone"]
                             call:^(NSTimeInterval duration) {
                                 NSLog(@"User made a call of %.1f seconds", duration);
                                 
                             } cancel:^{
                                 NSLog(@"User cancelled the call");
                             }];
    
    
    
    
    
    
    
    
}


-(void)address:(UIButton*)sender{
    commdity.adress=[commdity.Dict objectForKey:@"address"];
    NSString *oreillyAddress =commdity.adress;
    
    CLGeocoder *myGeocoder = [[CLGeocoder alloc] init];
    [myGeocoder geocodeAddressString:oreillyAddress completionHandler:^(NSArray *placemarks, NSError *error) {
        if ([placemarks count] > 0 && error == nil) {
            
            CLPlacemark *firstPlacemark = [placemarks objectAtIndex:0];
            double latitude=firstPlacemark.location.coordinate.longitude;
            NSString *latitudeString=[NSString stringWithFormat:@"%f",latitude];
            double longitude=firstPlacemark.location.coordinate.latitude;
            NSString *longitudeString=[NSString stringWithFormat:@"%f",longitude];
            NSLog(@"latitudeString= %@", longitudeString);
            NSLog(@"longitudeString= %@",latitudeString);
            NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                        commdity.adress,@"address",
                                        commdity.adress,@"city",
                                        @"google",@"from_map_type",
                                        commdity.adress,@"region", nil];
            
            [dic setValue:longitudeString forKey:@"google_lat"];
            [dic setValue:latitudeString forKey:@"google_lng"];
            
            NSLog(@"latitudeString= %@", longitudeString);
            NSLog(@"longitudeString= %@",latitudeString);
            
            
            MapViewControllers* h=[[MapViewControllers alloc] init];
            h.navDic=dic;
            h.mapType = RegionNavi;
            [self.navigationController pushViewController:h animated:YES];
            
            
            
        }
        else if ([placemarks count] == 0 && error == nil) {
            NSLog(@"Found no placemarks.");
        }
        else if (error != nil) {
            NSLog(@"An error occurred = %@", error); }
    }];
    
    
    
    
}

-(void)fenxiangss:(UIButton *)sender{
    
    
    [ACETelPrompt callPhoneNumber:[commdity.Dict objectForKey:@"phone"]
                             call:^(NSTimeInterval duration) {
                                 NSLog(@"User made a call of %.1f seconds", duration);
                                 
                             } cancel:^{
                                 NSLog(@"User cancelled the call");
                             }];
    

    
}
- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
@end